<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>详情页面</title>
    <style type="text/css">
        .searchArea .fieldBox .label {
            width: 70px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">

<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">申请人</div>
                    <div class="field">
                        <input name="crtUsrName" id="crtUsrName" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">所属事业部</div>
                    <div class="field">
                        <select name="buOrgCd" id="buOrgCd" data-value=" ">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${searchBuOrgList }" var="kv">
                                <option value="${kv.key }">${kv.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">申请时间</div>
                    <div class="field">
                        <input ligerui="width: 120" name="crtTm"
                               id="crtTm" type="text" class="ui-datepicker" value=""
                               validate="{required:true}">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">阶梯返利状态</div>
                    <div class="field">
                        <select name="applyState" id="applyState" data-value=" ">
                            <option value=" " seleted>全部</option>
                            <option value="1">未提交</option>
                            <option value="2">返利中</option>
                            <option value="3">已返利</option>
                            <option value="4">审核不通过</option>
                            <option value="5">不返利</option>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round"></i>清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>

    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    var callback = null;

    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/spl/rebates/initRebateRecord.do',
            parms: {},
            method: 'get',
            columns: [
                {display: '申请时间', name: 'crtTm', width: '20%',render: renderDate, align: 'center', enabledSort: false},
                {display: '申请人', name: 'crtUsrName', width: '10%', align: 'center', enabledSort: false},
                {display: '所属事业部', name: 'buOrgCdNm', width: '20%', align: 'center', enabledSort: false},
                {display: '阶梯返利状态', name: 'applyState', width: '10%', align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value){
                        if(value){
                            if(value == 1){
                                return "未提交";
                            }else if(value == 2){
                                return "返利中";
                            }else if(value == 3){
                                return "已返利";
                            }else if(value == 4){
                                return "审核不通过";
                            }else if(value == 5){
                                return "不返利";
                            }
                        }else{

                        }
                    }
                },
                {display: '阶梯返利金额', name: 'stepRebateAmt', width: '20%', align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value){
                        if(value){
                            return '￥  '+value/100;
                        }else{
                            return '￥   0.00';
                        }
                    }
                },
                {display: '流程编号', name: 'processNum', width: '20%', align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        if (value) {
                            var h = '<a href="javascript:showFlow(';
                            h += "'" + rowdata.processId + "'";
                            h += ",'"+rowdata.applyState+"'";
                            h += ",'" + rowdata.id + "'";
                            h += ')">' + value + '</a>';
                            return h;
                        }
                    }},
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            frozen: false
        });
        grid.setHeight(500);

        $("#searchBar").ligerForm();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "crtUsrName": " ",
                "crtTm": "",
                "buOrgCd" :"",
                "applyState":"",
            });
        });
        callback = function () {
            grid.reload();
        };

    });
    //显示流程
    function showFlow(_pInstId,_audStsCd,_businessKey){
        console.info(_audStsCd)
        if(StringUtils.isEmpty(_pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl = "/prjsteprebate/steprebateBscInfo/toDetailPage.do?isDetail=1@@id=";
        if(_audStsCd == 3 || _audStsCd == 4){
            var params = "?pInsId="+_pInstId+"&status=2&businessKey="+_businessKey+"&formUrl="+_formUrl;
        }else{
            var params = "?pInsId="+_pInstId+"&status=1&businessKey="+_businessKey+"&formUrl="+_formUrl;
        }
        Add_navTab('tab_spl_bank_flow_'+_pInstId,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }
    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
    function dialogCallback() {
        $.ligerDialog.hide();
        grid.reload();
    }

</script>

</body>
</html>
